package com.ling.pl.security.dao;

import com.ling.pl.security.model.DefaultCompany;
import org.springframework.stereotype.Component;
/**
 * @author bo.wang
 */
@Component(DefaultCompanyDao.BEAN_ID)
public class DefaultCompanyDao extends BaseDefaultCompanyDao {
    public void registerCompany(String id, String name, String desc) {
        DefaultCompany company = new DefaultCompany();
        company.setId(id);
        company.setName(name);
        company.setDesc(desc);
        save(company);
    }


    public String checkCompanyExist(String id) {
        String result = null;
        String sql = "SELECT COUNT(*) FROM DefaultCompany WHERE id=?";
        int count = queryForInt(sql, new Object[]{id});
        if (count > 0) {
            result = "公司ID已存在";
        }
        return result;
    }
}

